/**
 * 
 */
package niuke;

import java.util.HashSet;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 序列交换 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int[] a=new int[n];
		for (int i = 0; i < n; i++) {
			a[i]=scanner.nextInt();
		}
		
		int count=0;
		HashSet<Integer> sameMeet=new HashSet<>();
		for (int i = 0; i < a.length; i++) {
			for (int j = i+1; j < a.length; j++) {
				if(a[i]!=a[j]){
					count++;
				}else {
					if(sameMeet.add(a[i])){
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}

}
